from typing import Literal
from datetime import datetime
from pydantic import BaseModel, Field

KEY = Literal['code', 'id', 'value', 'end_value', 'state', 'start_time', 'end_time', 'name', 'group', 'serial_number', 'is_warning']


class AlarmsRequestCount(BaseModel):
    count: int = 0


class Filter(BaseModel):
    key: KEY
    value: bool | int | float | datetime | str


class NewAlarmsRequest(BaseModel):
    sort_by: KEY = 'start_time'
    order: Literal['asc', 'desc'] = 'desc'
    start_date: int = datetime(year=2018, month=1, day=1).timestamp()
    filters: list[Filter] = Field(default_factory=lambda: [Filter(key='state', value='true')])
    end_date: int = datetime(year=2036, month=1, day=1).timestamp()
    offset: int = 0
    count: int = 16
    language: str = 'en'
